package com.prs.crm.action.cqunicom;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.action.ReportAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.cdxh.SerialNumberss;
import com.prs.crm.domain.cqunicom.BusinessOrder;
import com.prs.crm.domain.cqunicom.BusinessRemind;
import com.prs.crm.domain.cqunicom.Company;
import com.prs.crm.domain.cqunicom.LogSerch;
import com.prs.crm.domain.cqunicom.MidBusinessOrder;
import com.prs.crm.domain.cqunicom.MonitorOrder;
import com.prs.crm.domain.cqunicom.NoteEditor;
import com.prs.crm.domain.cqunicom.NoteInformation;
import com.prs.crm.domain.cqunicom.OrderConnecting;
import com.prs.crm.domain.cqunicom.OrderDertyHistory;
import com.prs.crm.domain.cqunicom.PoplarOrder;
import com.prs.crm.domain.cqunicom.Services;
import com.prs.crm.domain.cqunicom.ServicesType;
import com.prs.crm.report.ExportConfig;
import com.prs.crm.report.ReportCell;
import com.prs.crm.report.ReportTable;
import com.prs.crm.service.cdxh.SerialNumberssService;
import com.prs.crm.service.cqunicom.BusinessOrderService;
import com.prs.crm.service.cqunicom.BusinessRemindService;
import com.prs.crm.service.cqunicom.CompanyService;
import com.prs.crm.service.cqunicom.LogSerchService;
import com.prs.crm.service.cqunicom.MidBusinessOrderService;
import com.prs.crm.service.cqunicom.MonitorOrderService;
import com.prs.crm.service.cqunicom.NoteEditorService;
import com.prs.crm.service.cqunicom.NoteInformationService;
import com.prs.crm.service.cqunicom.OrderConnectingService;
import com.prs.crm.service.cqunicom.OrderDertyHistoryService;
import com.prs.crm.service.cqunicom.OrderService;
import com.prs.crm.service.cqunicom.ServicesService;
import com.prs.crm.service.cqunicom.ServicesTypeService;
import com.prs.crm.service.hr.PersonService;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-3-2 下午03:26:28 简单说明
 */

public class OrderAction extends ReportAction {

	private static final long serialVersionUID = 1L;
	private PersonService personService;
	private PaginationSupport pagination;
	private LogSerchService logSerchService;
	private String rowdata;
	private Integer sid;
	private BusinessRemind businessRemind;
	private BusinessRemindService businessRemindService;
	private Company company;
	private NoteInformationService noteInformationService;
	private MidBusinessOrder midBusinessOrder;

	private MidBusinessOrderService midBusinessOrderService;

	private BusinessOrder businessOrder;

	private BusinessOrderService businessOrderService;

	private String orderState = "";
	private OrderConnecting OrderConnecting;
	private OrderConnectingService orderConnectingService;

	private MonitorOrder monitorOrder;

	private MonitorOrderService monitorOrderService;

	private CompanyService companyService;

	private PoplarOrder order;

	private OrderService orderService;
	private NoteEditor noteEditor;
	private NoteEditorService noteEditorService;
	private Services services;

	private ServicesService servicesService;

	private ServicesType servicesType;

	private ServicesTypeService servicesTypeService;

	private List<ServicesType> tyList;

	private String orderId = "";
	private String cusName = "";
	private String cusTel = "";
	private String design;
	private String initreserve = "";
	private SerialNumberss serialNumberss;

	private SerialNumberssService serialNumberssService;

	private Integer comm;

	private String modelsName;

	private String receiveState;

	private String busnesState;

	private Double dealPrice;

	private String outPerson;

	private Date outDate;

	private String cusDoxa;

	private Integer Encode = 0;

	private String busRemark;

	private String dealCause;

	private Date rserveTime;

	private String enjoyDegree;

	private Double tradeAmount;

	private Date visitTime;

	private String visitPerson;

	private String visitRemark;

	private String visitState;

	private Date startTimes = null;

	private Date endTimes = null;

	private String processState = "所有";

	/**
	 * 服务类别
	 */
	private Integer serviceClass = 0;
	/**
	 * 服务名称
	 */
	private Integer serverIdsss = 0;

	private String comName = "";
	private String customerName = "";
	private Integer comNameByid = 0;
	private String customerTel = "";
	private String orderCode;

	private List<Services> servicesList;
	private String workPattern1 = "转接";
	private String category;

	//
	private List<Services> serList;

	private String conditionss = "";

	private String sortStyle = "";

	private String bargainState = "";

	private Integer serverids = 0;

	private String dateSletct = "";

	private Date orderTime = null;

	private String teanTim = "";
	
	//gs
	private String gsA="";
	private String gsB="0";

	/**
	 * 订单修改元素
	 * 
	 * @return
	 */
	private OrderDertyHistory orderDertyHistory;

	private OrderDertyHistoryService orderDertyHistoryService;

	private int initsNum = 0;

	// 显示统计
	// 时间
	private String starts = "";
	private String ends = "";

	@Action("serchCustomersTs")
	public String serchCustomersTs() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				Company.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getCompanyService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
    //一般商家
	@Action("listOrder")
	public String listOrder() {

		
		tyList = this.getServicesTypeService().getAllServicesType();
		serList = this.getServicesService().getAllServices();
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}
		if (orderTime == null) {
			teanTim = ddf.format(new Date());
		} else {
			teanTim = ddf.format(orderTime);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		// 排序方式
		if ("时间".equals(sortStyle)) {
			criteria.addOrder(Order.asc("recordTime"));
		}

		if ("".equals(conditionss)) {

		} else if ("组查询".equals(conditionss)) {
			//System.out.println("进入组查询");
			// 共有关联属性
			if (!"所有".equals(bargainState) || !"所有".equals(processState)) {
			
				criteria.createAlias("businessOrder", "rr");
			}

			//System.out.println("交易状态：" + bargainState);
			if ("所有".equals(bargainState)) {// 交易状态

			} else {

				criteria.add(Restrictions
						.eq("rr.transationSatet", bargainState));
			}

		
			if ("所有".equals(processState)) {// 处理状态

			} else if ("未处理".equals(processState)) {
				criteria.add(Restrictions.eq("businessOrder", null));

			} else if ("处理中".equals(processState)) {
				criteria.add(Restrictions.isNotNull("rr.transationSatet"));

			} else if ("处理完毕".equals(processState)) {

				criteria.add(Restrictions.eq("rr.transationSatet", "已成交"));
			}

			
			
			if(serverIdsss==0){
				
			}else{
			Services ser = this.getServicesService().get(serverIdsss);// 服务名称

			criteria.add(Restrictions.eq("services", ser));
			}
			if("0".equals(gsB)){
				
			}else{
			Company com=this.getCompanyService().get(Integer.parseInt(gsB));//公司
			criteria.add(Restrictions.eq("company", com));
			}
		
			if ("派单时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("orderDate", startTimes,
						endTimes));
			} else if ("完成时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("compleDate", startTimes,
						endTimes));
			}
		} else if ("指定查询".equals(conditionss)) {
		
			if ("".equals(orderId)) {

			} else {
				criteria.add(Restrictions.eq("orderCode", orderId));
			}
			if ("".equals(cusName)) {

			} else {
				criteria.add(Restrictions.eq("customerName", cusName));
			}
			if ("".equals(cusTel)) {

			} else {
				criteria.add(Restrictions.eq("customerTel", cusTel));
			}
			
			
			
			criteria.add(Restrictions.eq("orderDate", orderTime));
		}

		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "一般商家"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订花服务
	@Action("listOrderFlower")
	public String listOrderFlower() {

		
		tyList = this.getServicesTypeService().getAllServicesType();
		serList = this.getServicesService().getAllServices();
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}
		if (orderTime == null) {
			teanTim = ddf.format(new Date());
		} else {
			teanTim = ddf.format(orderTime);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		// 排序方式
		if ("时间".equals(sortStyle)) {
			criteria.addOrder(Order.asc("recordTime"));
		}

		if ("".equals(conditionss)) {

		} else if ("组查询".equals(conditionss)) {
			//System.out.println("进入组查询");
			// 共有关联属性
			if (!"所有".equals(bargainState) || !"所有".equals(processState)) {
			
				criteria.createAlias("businessOrder", "rr");
			}

			//System.out.println("交易状态：" + bargainState);
			if ("所有".equals(bargainState)) {// 交易状态

			} else {

				criteria.add(Restrictions
						.eq("rr.transationSatet", bargainState));
			}

		
			if ("所有".equals(processState)) {// 处理状态

			} else if ("未处理".equals(processState)) {
				criteria.add(Restrictions.eq("businessOrder", null));

			} else if ("处理中".equals(processState)) {
				criteria.add(Restrictions.isNotNull("rr.transationSatet"));

			} else if ("处理完毕".equals(processState)) {

				criteria.add(Restrictions.eq("rr.transationSatet", "已成交"));
			}

			
			
			if(serverIdsss==0){
				
			}else{
			Services ser = this.getServicesService().get(serverIdsss);// 服务名称

			criteria.add(Restrictions.eq("services", ser));
			}
			if("0".equals(gsB)){
				
			}else{
			Company com=this.getCompanyService().get(Integer.parseInt(gsB));//公司
			criteria.add(Restrictions.eq("company", com));
			}
		
			if ("派单时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("orderDate", startTimes,
						endTimes));
			} else if ("完成时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("compleDate", startTimes,
						endTimes));
			}
		} else if ("指定查询".equals(conditionss)) {
		
			if ("".equals(orderId)) {

			} else {
				criteria.add(Restrictions.eq("orderCode", orderId));
			}
			if ("".equals(cusName)) {

			} else {
				criteria.add(Restrictions.eq("customerName", cusName));
			}
			if ("".equals(cusTel)) {

			} else {
				criteria.add(Restrictions.eq("customerTel", cusTel));
			}
			
			
			
			criteria.add(Restrictions.eq("orderDate", orderTime));
		}

		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订花服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订票服务
	@Action("listOrderTicker")
	public String listOrderTicker() {

		
		tyList = this.getServicesTypeService().getAllServicesType();
		serList = this.getServicesService().getAllServices();
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}
		if (orderTime == null) {
			teanTim = ddf.format(new Date());
		} else {
			teanTim = ddf.format(orderTime);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		// 排序方式
		if ("时间".equals(sortStyle)) {
			criteria.addOrder(Order.asc("recordTime"));
		}

		if ("".equals(conditionss)) {

		} else if ("组查询".equals(conditionss)) {
			//System.out.println("进入组查询");
			// 共有关联属性
			if (!"所有".equals(bargainState) || !"所有".equals(processState)) {
			
				criteria.createAlias("businessOrder", "rr");
			}

			//System.out.println("交易状态：" + bargainState);
			if ("所有".equals(bargainState)) {// 交易状态

			} else {

				criteria.add(Restrictions
						.eq("rr.transationSatet", bargainState));
			}

		
			if ("所有".equals(processState)) {// 处理状态

			} else if ("未处理".equals(processState)) {
				criteria.add(Restrictions.eq("businessOrder", null));

			} else if ("处理中".equals(processState)) {
				criteria.add(Restrictions.isNotNull("rr.transationSatet"));

			} else if ("处理完毕".equals(processState)) {

				criteria.add(Restrictions.eq("rr.transationSatet", "已成交"));
			}

			
			
			if(serverIdsss==0){
				
			}else{
			Services ser = this.getServicesService().get(serverIdsss);// 服务名称

			criteria.add(Restrictions.eq("services", ser));
			}
			if("0".equals(gsB)){
				
			}else{
			Company com=this.getCompanyService().get(Integer.parseInt(gsB));//公司
			criteria.add(Restrictions.eq("company", com));
			}
		
			if ("派单时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("orderDate", startTimes,
						endTimes));
			} else if ("完成时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("compleDate", startTimes,
						endTimes));
			}
		} else if ("指定查询".equals(conditionss)) {
		
			if ("".equals(orderId)) {

			} else {
				criteria.add(Restrictions.eq("orderCode", orderId));
			}
			if ("".equals(cusName)) {

			} else {
				criteria.add(Restrictions.eq("customerName", cusName));
			}
			if ("".equals(cusTel)) {

			} else {
				criteria.add(Restrictions.eq("customerTel", cusTel));
			}
			
			
			
			criteria.add(Restrictions.eq("orderDate", orderTime));
		}

		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订票服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订房服务
	@Action("listOrderHome")
	public String listOrderHome() {

		
		tyList = this.getServicesTypeService().getAllServicesType();
		serList = this.getServicesService().getAllServices();
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}
		if (orderTime == null) {
			teanTim = ddf.format(new Date());
		} else {
			teanTim = ddf.format(orderTime);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		// 排序方式
		if ("时间".equals(sortStyle)) {
			criteria.addOrder(Order.asc("recordTime"));
		}

		if ("".equals(conditionss)) {

		} else if ("组查询".equals(conditionss)) {
			//System.out.println("进入组查询");
			// 共有关联属性
			if (!"所有".equals(bargainState) || !"所有".equals(processState)) {
			
				criteria.createAlias("businessOrder", "rr");
			}

			//System.out.println("交易状态：" + bargainState);
			if ("所有".equals(bargainState)) {// 交易状态

			} else {

				criteria.add(Restrictions
						.eq("rr.transationSatet", bargainState));
			}

		
			if ("所有".equals(processState)) {// 处理状态

			} else if ("未处理".equals(processState)) {
				criteria.add(Restrictions.eq("businessOrder", null));

			} else if ("处理中".equals(processState)) {
				criteria.add(Restrictions.isNotNull("rr.transationSatet"));

			} else if ("处理完毕".equals(processState)) {

				criteria.add(Restrictions.eq("rr.transationSatet", "已成交"));
			}

			
			
			if(serverIdsss==0){
				
			}else{
			Services ser = this.getServicesService().get(serverIdsss);// 服务名称

			criteria.add(Restrictions.eq("services", ser));
			}
			if("0".equals(gsB)){
				
			}else{
			Company com=this.getCompanyService().get(Integer.parseInt(gsB));//公司
			criteria.add(Restrictions.eq("company", com));
			}
		
			if ("派单时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("orderDate", startTimes,
						endTimes));
			} else if ("完成时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("compleDate", startTimes,
						endTimes));
			}
		} else if ("指定查询".equals(conditionss)) {
		
			if ("".equals(orderId)) {

			} else {
				criteria.add(Restrictions.eq("orderCode", orderId));
			}
			if ("".equals(cusName)) {

			} else {
				criteria.add(Restrictions.eq("customerName", cusName));
			}
			if ("".equals(cusTel)) {

			} else {
				criteria.add(Restrictions.eq("customerTel", cusTel));
			}
			
			
			
			criteria.add(Restrictions.eq("orderDate", orderTime));
		}

		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订房服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订餐服务
	@Action("listOrderMeal")
	public String listOrderMeal() {

		
		tyList = this.getServicesTypeService().getAllServicesType();
		serList = this.getServicesService().getAllServices();
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}
		if (orderTime == null) {
			teanTim = ddf.format(new Date());
		} else {
			teanTim = ddf.format(orderTime);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		// 排序方式
		if ("时间".equals(sortStyle)) {
			criteria.addOrder(Order.asc("recordTime"));
		}

		if ("".equals(conditionss)) {

		} else if ("组查询".equals(conditionss)) {
			//System.out.println("进入组查询");
			// 共有关联属性
			if (!"所有".equals(bargainState) || !"所有".equals(processState)) {
			
				criteria.createAlias("businessOrder", "rr");
			}

			//System.out.println("交易状态：" + bargainState);
			if ("所有".equals(bargainState)) {// 交易状态

			} else {

				criteria.add(Restrictions
						.eq("rr.transationSatet", bargainState));
			}

		
			if ("所有".equals(processState)) {// 处理状态

			} else if ("未处理".equals(processState)) {
				criteria.add(Restrictions.eq("businessOrder", null));

			} else if ("处理中".equals(processState)) {
				criteria.add(Restrictions.isNotNull("rr.transationSatet"));

			} else if ("处理完毕".equals(processState)) {

				criteria.add(Restrictions.eq("rr.transationSatet", "已成交"));
			}

			
			
			if(serverIdsss==0){
				
			}else{
			Services ser = this.getServicesService().get(serverIdsss);// 服务名称

			criteria.add(Restrictions.eq("services", ser));
			}
			if("0".equals(gsB)){
				
			}else{
			Company com=this.getCompanyService().get(Integer.parseInt(gsB));//公司
			criteria.add(Restrictions.eq("company", com));
			}
		
			if ("派单时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("orderDate", startTimes,
						endTimes));
			} else if ("完成时间".equals(dateSletct)) {
				criteria.add(Restrictions.between("compleDate", startTimes,
						endTimes));
			}
		} else if ("指定查询".equals(conditionss)) {
		
			if ("".equals(orderId)) {

			} else {
				criteria.add(Restrictions.eq("orderCode", orderId));
			}
			if ("".equals(cusName)) {

			} else {
				criteria.add(Restrictions.eq("customerName", cusName));
			}
			if ("".equals(cusTel)) {

			} else {
				criteria.add(Restrictions.eq("customerTel", cusTel));
			}
			
			
			
			criteria.add(Restrictions.eq("orderDate", orderTime));
		}

		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订餐服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action(value = "exportOrderReport", results = { @Result(name = "success", type = "stream", params = {
			"contentType", "${contentType}", "inputName", "inputStream",
			"bufferSize", "1024", "contentDisposition",
			"filename=${outfileName}" }) })
	public String reportOrder() {
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("进行导出派单操作");
		this.getLogSerchService().save(log);
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.add(Restrictions.eq("processSucess", "2"));
		ReportTable table = new ReportTable("订单报表");
		table.addCell(new ReportCell("订单号", "orderCode"));
		table.addCell(new ReportCell("客户名称", "customerName"));
		table.addCell(new ReportCell("客户电话", "customerTel"));
		table.addCell(new ReportCell("交易状态", "businessOrder.transationSatet"));
		table.addCell(new ReportCell("成交价格", "businessOrder.dealPrice"));
		table.addCell(new ReportCell("下单时间", "orderDate"));
		table.addCell(new ReportCell("公司名称", "comName"));
		table.addCell(new ReportCell("回访状态", "monitorOrder.visitState"));
		table.addCell(new ReportCell("满意度", "monitorOrder.enjoyDegree"));
		table.addCell(new ReportCell("派单人员", "businessOrder.outPerson"));

		this.setOutFilePath(this.getReportService().report(criteria, table,
				new ExportConfig(), this.getExportType()));
		return SUCCESS;
	}

	/**
	 * 拒绝订单处理
	 * 
	 * @return
	 */
	@Action("listDeclineOrder")
	public String listDeclineOrder() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("person", AppContext.getAccountContext()
				.getUser()));
		criteria.add(Restrictions.eq("newOrderState", "3"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 拒绝订单
	 * 
	 * @return
	 */
	@Action("editWorkOrder")
	public String editWorkOrder() {

		return SUCCESS;
	}

	/**
	 * 重新制定派单
	 * 
	 * @return
	 * @throws UnsupportedEncodingException
	 * @throws MalformedURLException
	 */

	@Clew(results = { "success", "none" })
	@Action(value = "saveWorkOrder", results = {
			@Result(name = "success", type = "redirect", location = "listDeclineOrder"),
			@Result(name = "none", type = "redirect", location = "listDeclineOrder"),
			@Result(name = "error", type = "chain", location = "listDeclineOrder") })
	public String saveWorkOrder() throws MalformedURLException,
			UnsupportedEncodingException {
		// 模式区分 A：派单模式 B：转接模式
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("向商家:" + company.getComName() + "下了一个派单");
		this.getLogSerchService().save(log);

		PoplarOrder oo = this.getOrderService().get(order.getId());
		oo.setModleName("派单");

		/**
		 * 短信操作
		 */
		
		if ("是".equals(company.getState1())) {
			
			NoteInformation note = new NoteInformation();
			note.setPersonInfor(AppContext.getAccountContext().currentUser());
			note.setNoteNumber(company.getMobileNo());
			note.setNoteTitle("派单信息");
			String contents = getContents(services, company);
			String contgg = "尊敬的客户你有要处理的派单信息";
			if ("".equals(contents)) {

			} else {
				contgg = contents;
			}
			note.setNoteContent(contgg);
			this.getNoteInformationService().save(note);

			sendSMS4Other(company.getMobileNo(), contgg, new Date() + "");

		}

		oo.setServices(services);
		oo.setCompany(company);
		oo.setOrderStyles(1);
		oo.setOrderDate(new Date());
		oo.setRemindTime(0);
		oo.setBasicRemark("未填写");
		oo.setNewOrderState("1");
		oo.setHuifangUpdate("否");
		oo.setPerson(AppContext.getAccountContext().currentUser());
		this.getOrderService().saveOrupdate(oo);
		this.setPrompt("数据处理成功");
		return SUCCESS;
	}

	@Action("listAllOrder")
	public String listAllOrder() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		// criteria.add(Restrictions.not(Exprission.eq()));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("handworkOrder")
	public String handworkOrder() {
		return SUCCESS;
	}

	@Action("lookOrder")
	public String lookOrder() {

		return SUCCESS;
	}

	@Action("lookTransferOrder")
	public String lookTransferOrder() {
		servicesList = this.getServicesService().getByWorkPattern(workPattern1);
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "转接"));
        if(AppContext.getAccountContext().getUser().getRole().getId()==1){
        	
        }else{
		criteria.add(Restrictions.eq("company", AppContext.getAccountContext()
				.getUser().getCompanys()));
        }
		if (startTimes != null && endTimes != null) {
			criteria.add(Restrictions
					.between("orderDate", startTimes, endTimes));
		}

		if ("".equals(customerName) || customerName == null) {
		} else {
			criteria.add(Restrictions.eq("customerName", customerName));
		}
		if ("".equals(customerTel) || customerTel == null) {
		} else {
			criteria.add(Restrictions.eq("customerTel", customerTel));
		}
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action(value = "exportTransferOrderReport", results = { @Result(name = "success", type = "stream", params = {
			"contentType", "${contentType}", "inputName", "inputStream",
			"bufferSize", "1024", "contentDisposition",
			"filename=${outfileName}" }) })
	public String reportTransferOrder() {

		ReportTable table = new ReportTable("订单报表");
		table.addCell(new ReportCell("订单号", "orderCode"));
		table.addCell(new ReportCell("服务名称", "services.name"));
		table.addCell(new ReportCell("公司名称", "comName"));
		table.addCell(new ReportCell("客户名称", "customerName"));
		table.addCell(new ReportCell("客户电话", "customerTel"));
		table.addCell(new ReportCell("下单时间", "orderDate"));

		servicesList = this.getServicesService().getByWorkPattern(workPattern1);
		SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (startTimes == null) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -7);
			Date _currt = c.getTime();
			starts = ddf.format(_currt);// 开始时间
		} else {
			starts = ddf.format(startTimes);
		}
		if (endTimes == null) {
			ends = ddf.format(new Date());// 结束时间
		} else {
			ends = ddf.format(endTimes);
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "转接"));

		criteria.add(Restrictions.eq("company", AppContext.getAccountContext()
				.getUser().getCompanys()));
		if (startTimes != null && endTimes != null) {
			criteria.add(Restrictions
					.between("orderDate", startTimes, endTimes));
		}

		if ("".equals(customerName) || customerName == null) {
		} else {
			criteria.add(Restrictions.eq("customerName", customerName));
		}
		if ("".equals(customerTel) || customerTel == null) {
		} else {
			criteria.add(Restrictions.eq("customerTel", customerTel));
		}
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));

		this.setOutFilePath(this.getReportService().report(criteria, table,
				new ExportConfig(), this.getExportType()));
		return SUCCESS;
	}

	@Action("viewTransferOrder")
	public String viewTransferOrder() {
		
	

		return SUCCESS;
	}

	/**
	 * 创建对账信息
	 * 
	 * @return
	 */
	@Clew(results = { "success", "none" })
	@Action(value = "newAddOrderConnecting", results = {
			@Result(name = "success", type = "redirect", location = "lookTransferOrder"),
			@Result(name = "none", type = "redirect", location = "lookTransferOrder"),
			@Result(name = "error", type = "chain", location = "lookTransferOrder") })
	public String newAddOrderConnecting() {
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("发送了对账信息");
		this.getLogSerchService().save(log);

		List<PoplarOrder> po = this.getOrderService().getTraferOrder();
		OrderConnecting oc = new OrderConnecting();

		oc.setTrferNum(po.size() + "");
		oc.setStartTime(startTimes);
		oc.setEndTime(endTimes);
		oc.setSendTime(new Date());
		oc.setYnproblem("否");
		this.getOrderConnectingService().save(oc);
		this.setPrompt("对账数据信息发送中请稍等......");
		return SUCCESS;
	}

	/**
	 * 转接对账信息查询
	 * 
	 * @return
	 */

	@Action("listTransfertreconciliationOrder")
	public String listTransfertreconciliationOrder() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				OrderConnecting.class);

		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("lookOrderConnecting")
	public String looklookOrderConnecting() {

		return SUCCESS;
	}

	@Action("receivOrder")
	public String receivOrder() {

		return SUCCESS;
	}

	@Action("alterPopOrder")
	public String alterPopOrder() {

		return SUCCESS;
	}
//一般商家
	@Action("alterOrder")
	public String alterOrder() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "一般商家"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	
	//订花服务   alterOrderFlower
	@Action("alterOrderFlower")
	public String alterOrderFlower() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订花服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订票服务   alterOrderTicker
	@Action("alterOrderTicker")
	public String alterOrderTicker() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订票服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订房服务   alterOrderHome
	@Action("alterOrderHome")
	public String alterOrderHome() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订房服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	//订餐服务   alterOrderMeal
	@Action("alterOrderMeal")
	public String alterOrderMeal() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.createAlias("company", "cc");
		criteria.add(Restrictions.eq("cc.comStyles", "订餐服务"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 手工订单注册，商家
	 * 
	 * @return
	 */
	@Action("OrderCommpInsert")
	public String OrderCommpInsert() {
		Services cp = this.getServicesService().get(comm);
		List<MidBusinessOrder> slist = this.getMidBusinessOrderService()
				.getMidBusinessOrder(cp);
		List<Integer> comList = new ArrayList<Integer>();
		for (MidBusinessOrder com : slist) {
			comList.add(com.getCompanym().getId());
		}

		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				Company.class);

		pagination = this.getPaginationHelper().prepare(pagination);
		// criteria.add(Restrictions.eq("comType",
		// cp.getServicesType().getName()));
		// criteria.add(Restrictions.eq("comServices", cp.getName()));
		if (comList.size() == 0) {
			criteria.add(Restrictions.eq("id", 0));
		} else {
			criteria.add(Restrictions.in("id", comList));
		}
		criteria.add(Restrictions.eq("state2", "否"));
		this.setPagination(this.getCompanyService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("OrderPersonInsert")
	public String OrderPersonInsert() {
		String fig = "";
		if (design.equals("A")) {
			fig = "派单";
		} else {
			fig = "转接";
		}
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				Services.class);
		criteria.add(Restrictions.eq("workPattern", fig));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getServicesTypeService().listByPage(criteria,
				pagination));

		return SUCCESS;
	}

	@Action(value = "productCodess", results = { @Result(name = "success", type = "json", params = {
			"root", "rowdata" }) })
	public String productCodess() {

		Services ser = this.getServicesService().get(sid);

		this.rowdata = getSerialCode(ser);
		return SUCCESS;
	}

	/**
	 * 修改订单
	 * 
	 * @return
	 * @throws ParseException
	 */
	@Clew(results = { "success", "none" })
	@Action(value = "alterUpdateOrder", results = {
			@Result(name = "success", type = "redirect", location = "alterOrder"),
			@Result(name = "none", type = "redirect", location = "alterOrder"),
			@Result(name = "error", type = "chain", location = "alterOrder") })
	public String alterUpdateOrder() throws ParseException {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		PoplarOrder po = this.getOrderService().get(order.getId());
		// 商家信息变更
		BusinessOrder bo = this.getBusinessOrderService().get(
				po.getBusinessOrder().getId());
		bo.setTransationSatet(orderDertyHistory.getOrjystate());
		if ("".equals(orderDertyHistory.getOrcjPrice())) {
			bo.setDealPrice(0.0);
		} else {
			bo.setDealPrice(Double.parseDouble(orderDertyHistory.getOrcjPrice()));
		}
		bo.setOutPerson(orderDertyHistory.getOrwpPerson());
		bo.setOutDate(df.parse(orderDertyHistory.getOrwpTime()));
		bo.setCusDoxa(orderDertyHistory.getOrcusyj());
		bo.setBusRemark(orderDertyHistory.getOrRemak1());
		this.getBusinessOrderService().submit(bo);
		// 班长信息
		MonitorOrder mo = this.getMonitorOrderService().get(
				po.getMonitorOrder().getId());
		mo.setEnjoyDegree(orderDertyHistory.getOrcusmyd());
		if ("".equals(orderDertyHistory.getOrjyMony())) {
			mo.setTradeAmount(0.0);
		} else {
			mo.setTradeAmount(Double.parseDouble(orderDertyHistory
					.getOrjyMony()));
		}
		mo.setVisitState(orderDertyHistory.getOrhfState());
		mo.setVisitTime(df.parse(orderDertyHistory.getOrhfTime()));
		mo.setVisitPerson(orderDertyHistory.getOrhfPerson());
		mo.setVisitRemark(orderDertyHistory.getOrRemark2());
		this.getMonitorOrderService().submit(mo);
		po.setHuifangUpdate("是");
		po.setUpdateYuan(orderDertyHistory.getOrUpyy());
		this.getOrderService().saveOrupdate(po);
		OrderDertyHistory ooK = this.getOrderDertyHistoryService()
				.getByOrderId(order.getId() + "");
		if (ooK == null) {
			orderDertyHistory.setRecordNum(1);
		} else {
			orderDertyHistory.setRecordNum(ooK.getRecordNum() + 1);
		}
		this.getOrderDertyHistoryService().save(orderDertyHistory);
		this.setPrompt("修改订单成功");
		return SUCCESS;
	}

	/**
	 * 查看以前订单计算
	 * 
	 * @return
	 */

	@Action("historyOrders")
	public String historyOrders() {
		if (initsNum == 0) {

			List<OrderDertyHistory> alist = this.getOrderDertyHistoryService()
					.getByMaxOrderId(order.getId() + "");
			int start = 0;
			for (OrderDertyHistory kk : alist) {
				//System.out.println("s:" + kk.getRecordNum());
				if (kk.getRecordNum() > start) {
					initsNum = kk.getRecordNum();
					orderDertyHistory = kk;
				}
			}

		} else {
			orderDertyHistory = this.getOrderDertyHistoryService()
					.getByaddOrderId(initsNum);
			initsNum = initsNum - 1;
		}
		return SUCCESS;
	}

	@Clew(results = { "success", "none" })
	@Action(value = "receivOrderS", results = {
			@Result(name = "success", type = "redirect", location = "listBusinessOrder"),
			@Result(name = "none", type = "redirect", location = "listBusinessOrder"),
			@Result(name = "error", type = "chain", location = "listBusinessOrder") })
	public String receivOrderS() {
		PoplarOrder pop = this.getOrderService().get(order.getId());
		pop.setNewOrderState(receiveState);
		pop.setAccpectPerson(AppContext.getAccountContext().currentUser());
		pop.setAccpectDate(new Date());
		pop.setProcessSucess("1");// 是否处理完成的初始化
		pop.setBasicRemark(order.getBasicRemark());
		this.getOrderService().submit(pop);
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		// 修改提醒
		BusinessRemind ok = this.getBusinessRemindService()
				.getByBusinessRemind(pop);
		ok.setReadYN("2");
		this.getBusinessRemindService().saveOrupdate(ok);
		if ("2".equals(receiveState)) {
			this.setPrompt("接单操作已成功");
			log.setCandleContents("进行了接单操作");

		} else {
			this.setPrompt("你已拒绝此订单");
			log.setCandleContents("拒绝了订单的操作");
		}
		this.getLogSerchService().save(log);
		return SUCCESS;

	}

	@Action("buinessProcessOrder")
	public String buinessProcessOrder() {
		if (order != null) {
			businessOrder = this.getOrderService().get(order.getId())
					.getBusinessOrder();
			if (businessOrder == null || "".equals(businessOrder)) {
			} else {
				SimpleDateFormat ddf = new SimpleDateFormat(
						"yyyy-MM-dd HH:mm:ss");
				if (businessOrder.getRserveTime() == null
						|| "".equals(businessOrder.getRserveTime())) {

				} else {
					initreserve = ddf.format(businessOrder.getRserveTime());
				}
			}
		}

		return SUCCESS;
	}

	@Clew(results = { "success", "none" })
	@Action(value = "OrderProcess", results = {
			@Result(name = "success", type = "redirect", location = "listBusinessProcessOrder"),
			@Result(name = "none", type = "redirect", location = "listBusinessProcessOrder"),
			@Result(name = "error", type = "chain", location = "buinessProcessOrder") })
	public String OrderProcess() {
	

		PoplarOrder pop = this.getOrderService().get(order.getId());
		if ("未成交".equals(busnesState)) {
			pop.setProcessSucess("2");
			pop.setCompleDate(new Date());
			if (businessOrder.getId() == null) {
				BusinessOrder bo = new BusinessOrder();
				bo.setTransationSatet(busnesState);
				bo.setDealCause(dealCause);
				this.getBusinessOrderService().save(bo);
				pop.setBusinessOrder(bo);
			} else {
			}
			this.getOrderService().saveOrupdate(pop);
		} else if ("已成交".equals(busnesState)) {
			pop.setProcessSucess("2");
			pop.setCompleDate(new Date());
			if (businessOrder.getId() == null) {
				BusinessOrder bo = new BusinessOrder();
				bo.setPersonbus(AppContext.getAccountContext().getUser());
				bo.setTransationSatet(busnesState);
				bo.setDealPrice(dealPrice);
				bo.setOutPerson(outPerson);
				bo.setOutDate(outDate);
				bo.setCusDoxa(cusDoxa);
				bo.setBusRemark(busRemark);
				this.getBusinessOrderService().save(bo);
				pop.setBusinessOrder(bo);
			} else {
				BusinessOrder bor = this.getBusinessOrderService().get(
						businessOrder.getId());
				bor.setTransationSatet(busnesState);
				bor.setDealPrice(dealPrice);
				bor.setOutPerson(outPerson);
				bor.setOutDate(outDate);
				bor.setCusDoxa(cusDoxa);
				bor.setBusRemark(busRemark);
				this.getBusinessOrderService().submit(bor);
			}
			this.getOrderService().saveOrupdate(pop);

		} else if ("考虑中".equals(busnesState)) {
			if (businessOrder.getId() == null) {
				BusinessOrder bo = new BusinessOrder();
				bo.setPersonbus(AppContext.getAccountContext().getUser());
				bo.setTransationSatet(busnesState);
				this.getBusinessOrderService().save(bo);
				pop.setBusinessOrder(bo);
			} else {
				BusinessOrder bor = this.getBusinessOrderService().get(
						businessOrder.getId());
				bor.setTransationSatet(busnesState);
				this.getBusinessOrderService().submit(bor);
			}
			this.getOrderService().saveOrupdate(pop);
		} else if ("进行中".equals(busnesState)) {
			if (businessOrder.getId() == null) {
				BusinessOrder bo = new BusinessOrder();
				bo.setPersonbus(AppContext.getAccountContext().getUser());
				bo.setTransationSatet(busnesState);
				bo.setDealPrice(dealPrice);
				bo.setOutPerson(outPerson);
				bo.setOutDate(outDate);
				bo.setCusDoxa(cusDoxa);
				bo.setBusRemark(busRemark);
				this.getBusinessOrderService().save(bo);
				pop.setBusinessOrder(bo);
			} else {
				BusinessOrder bor = this.getBusinessOrderService().get(
						businessOrder.getId());
				bor.setTransationSatet(busnesState);
				bor.setDealPrice(dealPrice);
				bor.setOutPerson(outPerson);
				bor.setOutDate(outDate);
				bor.setCusDoxa(cusDoxa);
				bor.setBusRemark(busRemark);
				this.getBusinessOrderService().submit(bor);
			}
			this.getOrderService().saveOrupdate(pop);
		} else if ("预约".equals(busnesState)) {
			if (businessOrder.getId() == null) {
				BusinessOrder bo = new BusinessOrder();
				bo.setPersonbus(AppContext.getAccountContext().getUser());
				bo.setTransationSatet(busnesState);
				bo.setDealPrice(dealPrice);
				bo.setOutPerson(outPerson);
				bo.setOutDate(outDate);
				bo.setCusDoxa(cusDoxa);
				bo.setBusRemark(busRemark);
				bo.setRserveTime(rserveTime);
				this.getBusinessOrderService().save(bo);
				pop.setBusinessOrder(bo);
			} else {
				BusinessOrder bor = this.getBusinessOrderService().get(
						businessOrder.getId());
				bor.setTransationSatet(busnesState);
				bor.setDealPrice(dealPrice);
				bor.setOutPerson(outPerson);
				bor.setOutDate(outDate);
				bor.setCusDoxa(cusDoxa);
				bor.setBusRemark(busRemark);
				bor.setRserveTime(rserveTime);
				this.getBusinessOrderService().submit(bor);
			}
			this.getOrderService().saveOrupdate(pop);
		}

		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("进行了订单的处理");
		this.getLogSerchService().save(log);
		this.setPrompt("处理订单完成");
		return SUCCESS;

	}

	@Clew(results = { "success", "none" })
	@Action(value = "saveAllOrderS", results = {
			@Result(name = "success", type = "redirect", location = "handworkOrder"),
			@Result(name = "none", type = "redirect", location = "handworkOrder"),
			@Result(name = "error", type = "chain", location = "handworkOrder") })
	public String saveAllOrderS() {
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		Company com = this.getCompanyService().get(company.getId());
		// 模式区分 A：派单模式 B：转接模式
		String xx="1";
		if ("A".equals(modelsName)) {
			log.setCandleContents("建立了新的派单");
			order.setModleName("派单");
			/**
			 * 短信操作
			 */

			//System.out.println("是不是发短信状态:" + com.getState1());
			if ("是".equals(com.getState1())) {
				NoteInformation note = new NoteInformation();
				note.setPersonInfor(AppContext.getAccountContext()
						.currentUser());
				note.setNoteNumber(com.getMobileNo());
				note.setNoteTitle("派单信息");

				String contents = getContents(services, company);
				String contgg = "尊敬的客户你有要处理的派单信息";
				if ("".equals(contents)) {

				} else {
					contgg = contents;
				}
				note.setNoteContent(contgg);
				this.getNoteInformationService().save(note);
				try {
					//System.out.println("company.getMobileNo():"+ com.getMobileNo());
					sendSMS4Other(com.getMobileNo(), contgg, new Date() + "");
				} catch (MalformedURLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		} else {
			log.setCandleContents("建立了新的转接单");
			order.setModleName("转接");
			xx="2";
			/**
			 * 短信操作
			 */

			if ("是".equals(com.getState1())) {
				NoteInformation note = new NoteInformation();
				note.setPersonInfor(AppContext.getAccountContext()
						.currentUser());
				note.setNoteNumber(com.getMobileNo());
				note.setNoteTitle("转接信息");

				String contents = getContents(services, company);
				String contgg = "尊敬的客户你有要处理的派单信息";
				if ("".equals(contents)) {

				} else {
					contgg = contents;
				}
				note.setNoteContent(contgg);

				this.getNoteInformationService().save(note);
				try {
					sendSMS4Other(com.getMobileNo(), contgg, new Date() + "");
				} catch (MalformedURLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		order.setServices(services);
		order.setCompany(company);
		order.setOrderStyles(1);
		order.setOrderDate(new Date());
		order.setRemindTime(0);
		order.setBasicRemark("未填写");
		order.setNewOrderState("1");
		order.setHuifangUpdate("否");
		order.setPerson(AppContext.getAccountContext().currentUser());
		order.setAudState(0);
		order.setTredeSatets(0);
		order.setPriColor(0);
		this.getOrderService().save(order);
		this.setPrompt("手工订单创建成功");
		this.getLogSerchService().save(log);

		BusinessRemind br = new BusinessRemind();
		br.setCompanyRemind(com);
		br.setReadYN(xx);
		br.setRemindOrder(order);
		this.getBusinessRemindService().save(br);
		return SUCCESS;
	}

	/**
	 * 商家派单模式
	 * 
	 * @return
	 */
	@Action("listBusinessOrder")
	public String listBusinessOrder() {
		//System.out.println("当前用户:"+ AppContext.getAccountContext().currentUser().getCompanys());
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("company", AppContext.getAccountContext()
				.currentUser().getCompanys()));
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.add(Restrictions.eq("newOrderState", "1"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 商家派单模式
	 * 
	 * @return
	 */
	@Action("listBusinessTransferOrder")
	public String listBusinessTransferOrder() {
		//System.out.println("当前用户:"+ AppContext.getAccountContext().currentUser().getUserName());
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("company", AppContext.getAccountContext()
				.currentUser().getCompanys()));
		criteria.add(Restrictions.eq("modleName", "转接"));
		criteria.add(Restrictions.eq("newOrderState", "1"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 商家订单查询
	 * 
	 * @return
	 */

	
	@Action("listCompanyOrder")
	public String listCompanyOrder() {
		//System.out.println("当前用户:"+ AppContext.getAccountContext().currentUser().getCompanys());
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("company", AppContext.getAccountContext()
				.currentUser().getCompanys()));
		criteria.add(Restrictions.eq("modleName", "派单"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}
	@Action("listBusinessProcessOrder")
	public String listBusinessProcessOrder() {
		setRemindTime();
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.eq("company", AppContext.getAccountContext()
				.currentUser().getCompanys()));
		criteria.add(Restrictions.eq("processSucess", "1"));
		criteria.add(Restrictions.eq("newOrderState", "2"));

		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("listmonitorOrder")
	public String listmonitorOrder() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.createAlias("businessOrder", "bus");
		criteria.add(Restrictions.or(Restrictions.eq("bus.transationSatet","已成交"), Restrictions.eq("bus.transationSatet","未成交")));
		criteria.add(Restrictions.isNull("monitorOrder"));
		criteria.add(Restrictions.eq("modleName", "派单"));
		criteria.add(Restrictions.eq("newOrderState", "2"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 交易查询
	 * 
	 * @return
	 */
	@Action("listtradeOrder")
	public String listtradeOrder() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 交易统计
	 * 
	 * @return
	 */
	@Action("liststatsOrder")
	public String liststatsOrder() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	/**
	 * 对账查询
	 * 
	 * @return
	 */

	@Action("listreconciliationOrder")
	public String listreconciliationOrder() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("listmonitorOrderRecord")
	public String listmonitorOrderRecord() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);
		criteria.add(Restrictions.isNotNull("monitorOrder"));
		criteria.add(Restrictions.eq("modleName", "派单"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	@Action("monitorBackOrder")
	public String monitorBackOrder() {
		return SUCCESS;
	}

	@Clew(results = { "success", "none" })
	@Action(value = "savemonitotOrder", results = {
			@Result(name = "success", type = "redirect", location = "listmonitorOrder"),
			@Result(name = "none", type = "redirect", location = "listmonitorOrder"),
			@Result(name = "error", type = "chain", location = "listmonitorOrder") })
	public String savemonitotOrder() {
		PoplarOrder pg = this.getOrderService().get(order.getId());
		MonitorOrder mp = new MonitorOrder();
		mp.setPersonTeam(AppContext.getAccountContext().getUser());
		mp.setEnjoyDegree(enjoyDegree);
		mp.setVisitState(visitState);
		mp.setTradeAmount(tradeAmount);
		mp.setVisitTime(visitTime);
		mp.setVisitPerson(visitPerson);
		mp.setVisitRemark(visitRemark);
		this.getMonitorOrderService().save(mp);
		pg.setMonitorOrder(mp);
		this.getOrderService().saveOrupdate(pg);
		this.setPrompt("回执信息修改完成");
		LogSerch log = new LogSerch();
		log.setCandlePeron(AppContext.getAccountContext().currentUser()
				.getUserName());
		log.setCandleContents("进行了回执信息的修改");
		this.getLogSerchService().save(log);

		return SUCCESS;
	}

	/**
	 * 交易订单状态查询
	 * 
	 * @return
	 */
	@Action("listTradeState")
	public String listTradeState() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				PoplarOrder.class);

		if ("".equals(orderState) || orderState == null) {

		} else {
			if ("所有".equals(orderState)) {
			} else {
				criteria.createAlias("businessOrder", "rr");
				criteria.add(Restrictions.eq("rr.transationSatet", orderState));
			}
			if ("".equals(orderCode) || orderCode == null) {
			} else {
				criteria.add(Restrictions.eq("orderCode", orderCode));
			}
			if ("".equals(customerName) || customerName == null) {
			} else {
				criteria.add(Restrictions.eq("customerName", customerName));
			}
			if ("".equals(customerTel) || customerTel == null) {
			} else {
				criteria.add(Restrictions.eq("customerTel", customerTel));
			}

		}

		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getOrderService().listByPage(criteria,
				pagination));
		return SUCCESS;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public PoplarOrder getOrder() {
		return order;
	}

	public String getModelsName() {
		return modelsName;
	}

	public void setModelsName(String modelsName) {
		this.modelsName = modelsName;
	}

	public void setOrder(PoplarOrder order) {
		this.order = order;
	}

	public String getEnjoyDegree() {
		return enjoyDegree;
	}

	public void setEnjoyDegree(String enjoyDegree) {
		this.enjoyDegree = enjoyDegree;
	}

	public Double getTradeAmount() {
		return tradeAmount;
	}

	public void setTradeAmount(Double tradeAmount) {
		this.tradeAmount = tradeAmount;
	}

	public Date getVisitTime() {
		return visitTime;
	}

	public void setVisitTime(Date visitTime) {
		this.visitTime = visitTime;
	}

	public String getVisitPerson() {
		return visitPerson;
	}

	public void setVisitPerson(String visitPerson) {
		this.visitPerson = visitPerson;
	}

	public String getVisitRemark() {
		return visitRemark;
	}

	public void setVisitRemark(String visitRemark) {
		this.visitRemark = visitRemark;
	}

	public String getVisitState() {
		return visitState;
	}

	public void setVisitState(String visitState) {
		this.visitState = visitState;
	}

	public OrderService getOrderService() {
		return orderService;
	}

	public Integer getComm() {
		return comm;
	}

	public void setComm(Integer comm) {
		this.comm = comm;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

	public Services getServices() {
		return services;
	}

	public void setServices(Services services) {
		this.services = services;
	}

	public ServicesService getServicesService() {
		return servicesService;
	}

	public void setServicesService(ServicesService servicesService) {
		this.servicesService = servicesService;
	}

	public ServicesType getServicesType() {
		return servicesType;
	}

	public MonitorOrder getMonitorOrder() {
		return monitorOrder;
	}

	public void setMonitorOrder(MonitorOrder monitorOrder) {
		this.monitorOrder = monitorOrder;
	}

	public MonitorOrderService getMonitorOrderService() {
		return monitorOrderService;
	}

	public void setMonitorOrderService(MonitorOrderService monitorOrderService) {
		this.monitorOrderService = monitorOrderService;
	}

	public void setServicesType(ServicesType servicesType) {
		this.servicesType = servicesType;
	}

	public ServicesTypeService getServicesTypeService() {
		return servicesTypeService;
	}

	public void setServicesTypeService(ServicesTypeService servicesTypeService) {
		this.servicesTypeService = servicesTypeService;
	}

	public List<ServicesType> getTyList() {
		return tyList;
	}

	public void setTyList(List<ServicesType> tyList) {
		this.tyList = tyList;
	}

	public String getRowdata() {
		return rowdata;
	}

	public void setRowdata(String rowdata) {
		this.rowdata = rowdata;
	}

	public Integer getSid() {
		return sid;
	}

	public BusinessOrder getBusinessOrder() {
		return businessOrder;
	}

	public void setBusinessOrder(BusinessOrder businessOrder) {
		this.businessOrder = businessOrder;
	}

	public BusinessOrderService getBusinessOrderService() {
		return businessOrderService;
	}

	public void setBusinessOrderService(
			BusinessOrderService businessOrderService) {
		this.businessOrderService = businessOrderService;
	}

	public Double getDealPrice() {
		return dealPrice;
	}

	public void setDealPrice(Double dealPrice) {
		this.dealPrice = dealPrice;
	}

	public String getOutPerson() {
		return outPerson;
	}

	public void setOutPerson(String outPerson) {
		this.outPerson = outPerson;
	}

	public Date getOutDate() {
		return outDate;
	}

	public void setOutDate(Date outDate) {
		this.outDate = outDate;
	}

	public String getCusDoxa() {
		return cusDoxa;
	}

	public void setCusDoxa(String cusDoxa) {
		this.cusDoxa = cusDoxa;
	}

	public String getBusRemark() {
		return busRemark;
	}

	public void setBusRemark(String busRemark) {
		this.busRemark = busRemark;
	}

	public String getDealCause() {
		return dealCause;
	}

	public void setDealCause(String dealCause) {
		this.dealCause = dealCause;
	}

	public Date getRserveTime() {
		return rserveTime;
	}

	public void setRserveTime(Date rserveTime) {
		this.rserveTime = rserveTime;
	}

	public void setSid(Integer sid) {
		this.sid = sid;
	}

	public String getDesign() {
		return design;
	}

	public void setDesign(String design) {
		this.design = design;
	}

	public SerialNumberss getSerialNumberss() {
		return serialNumberss;
	}

	public void setSerialNumberss(SerialNumberss serialNumberss) {
		this.serialNumberss = serialNumberss;
	}

	public SerialNumberssService getSerialNumberssService() {
		return serialNumberssService;
	}

	public void setSerialNumberssService(
			SerialNumberssService serialNumberssService) {
		this.serialNumberssService = serialNumberssService;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public CompanyService getCompanyService() {
		return companyService;
	}

	public void setCompanyService(CompanyService companyService) {
		this.companyService = companyService;
	}

	public String getReceiveState() {
		return receiveState;
	}

	public void setReceiveState(String receiveState) {
		this.receiveState = receiveState;
	}

	public String getBusnesState() {
		return busnesState;
	}

	public void setBusnesState(String busnesState) {
		this.busnesState = busnesState;
	}

	public String getSerialCode(Services ser) {
		SerialNumberss snb = this.getSerialNumberssService()
				.getSerialNumberssOrder(ser.getName(), ser.getSimplename());

		if (snb != null) {
			// 不为空
			String currentString = backmidleValue();
			String dbString = snb.getStyNumberCode();
			String ak[] = dbString.split(currentString);
			int lengths = ak.length;
			if (lengths == 2) {
				String codes = ak[0] + backmidleValue() + addtional(ak[1]);
				snb.setStyNumberCode(codes);
				this.getSerialNumberssService().submit(snb);

				return codes;
			} else {
				String codes = ser.getSimplename() + backmidleValue() + "0001";
				snb.setStyNumberCode(codes);
				this.getSerialNumberssService().submit(snb);

				return codes;
			}

		} else {
			// 为空的时候
			String codes = ser.getSimplename() + backmidleValue() + "0001";
			SerialNumberss ss = new SerialNumberss();
			ss.setJudgStyle(ser.getName());
			ss.setStyNumberCode(codes);
			ss.setStyCategory(ser.getSimplename());
			this.getSerialNumberssService().save(ss);

			return codes;
		}

	}

	public String backmidleValue() {
		SimpleDateFormat gs = new SimpleDateFormat("yyyy-MM-dd");
		String currentDate = gs.format(new Date());
		String currents = currentDate.replace("-", "");
		return currents;
	}

	public String addtional(String numbe) {
		int startNum = Integer.parseInt(numbe);
		String endNun = (startNum + 1) + "";
		int cicles = 4 - endNun.length();
		for (int i = 0; i < cicles; i++) {
			endNun = "0" + endNun;
		}
		return endNun;
	}

	/**
	 * 设置提醒次数
	 */
	public void setRemindTime() {

		List<PoplarOrder> orderlist = this.getOrderService().getAllOrderList();
		int siess = orderlist.size();
		if (siess > 0) {

			for (PoplarOrder od : orderlist) {
				//System.out.println("处理ID值：" + od.getId());
				int inits = 0;
				if ("1".equals(od.getNewOrderState())) {
					long between = (new Date().getTime() - od.getRecordTime()
							.getTime()) / 1000;// 除以1000是为了转换成秒
					long betweens = (between / 60) / 3;// 提醒次数
					od.setRemindTime(betweens);
					inits++;
					//System.out.println("提醒次数：" + betweens);
				}
				if ("2".equals(od.getProcessSucess())) {
					long seconds = (od.getCompleDate().getTime() - od
							.getAccpectDate().getTime()) / 1000;
					long timeLengths = (seconds / 60) / 60;
					od.setHandleTime(timeLengths + "小时");
					inits++;
					//System.out.println("处理时长：" + timeLengths);
				}
				if (inits > 0) {

					this.getOrderService().submit(od);
				}

			}
		}

	}

	/**
	 * 单据自动处理
	 */
	public void processOrders() {
		List<PoplarOrder> orderlist = this.getOrderService().getAllOrderList();
		// 坐席下单后24小时未处理的处理
		for (PoplarOrder OO : orderlist) {
			if ("".equals(OO.getAccpectDate()) || OO.getAccpectDate() == null) {
				Date orderTime = OO.getRecordTime();
				long timzs = (new Date().getTime() - orderTime.getTime()) / 1000 / 60 / 60;
				if (timzs > 24) {
					OO.setCompleDate(new Date());
					OO.setProcessSucess("2");
					BusinessOrder bo = new BusinessOrder();
					bo.setTransationSatet("未成交");
					bo.setBusRemark("坐席下单后该订单超过24小时商家未进行接单处理,系统自动处理!");
					this.getBusinessOrderService().save(bo);
					OO.setBusinessOrder(bo);
					this.getOrderService().saveOrupdate(OO);
				}
			} else {
				// 不为空情况
				if ("进行中".equals(OO.getBusinessOrder().getTransationSatet())) {
					Date orderTime = OO.getRecordTime();
					long timzs = (new Date().getTime() - orderTime.getTime()) / 1000 / 60 / 60;
					if (timzs > 24) {
						OO.setCompleDate(new Date());
						OO.setProcessSucess("2");

						BusinessOrder bo = this.getBusinessOrderService().get(
								OO.getBusinessOrder().getId());
						bo.setTransationSatet("已成交");
						bo.setBusRemark("坐席下单后24小时内未处理进行中的订单,系统自动处理");
						this.getBusinessOrderService().save(bo);
						this.getOrderService().saveOrupdate(OO);
					}
				}
				if ("考虑中".equals(OO.getBusinessOrder().getTransationSatet())) {
					Date orderTime = OO.getRecordTime();
					long timzs = (new Date().getTime() - orderTime.getTime()) / 1000 / 60 / 60;
					if (timzs > 24) {
						OO.setCompleDate(new Date());
						OO.setProcessSucess("2");

						BusinessOrder bo = this.getBusinessOrderService().get(
								OO.getBusinessOrder().getId());
						bo.setTransationSatet("未成交");
						bo.setBusRemark("坐席下单后24小时内未处理考虑中的订单,系统自动处理");
						this.getBusinessOrderService().save(bo);
						this.getOrderService().saveOrupdate(OO);
					}
				}
				if ("预约".equals(OO.getBusinessOrder().getTransationSatet())) {

					Date reserveTime = OO.getBusinessOrder().getRserveTime();
					long timzs = (reserveTime.getTime() - new Date().getTime()) / 1000 / 60 / 60;
					if (timzs < 2 && timzs > 0) {
						// 需要提醒
					} else if (timzs < -24) {
						OO.setCompleDate(OO.getBusinessOrder().getRserveTime());
						OO.setProcessSucess("2");

						BusinessOrder bo = this.getBusinessOrderService().get(
								OO.getBusinessOrder().getId());
						bo.setTransationSatet("已成交");
						bo.setBusRemark("坐席下单后24小时未对预约的订单进行处理,系统自动处理");
						this.getBusinessOrderService().save(bo);
						this.getOrderService().saveOrupdate(OO);
					}
				}

			}
		}

	}

	public List<Services> getServicesList() {
		return servicesList;
	}

	public void setServicesList(List<Services> servicesList) {
		this.servicesList = servicesList;
	}

	public String getWorkPattern1() {
		return workPattern1;
	}

	public OrderDertyHistory getOrderDertyHistory() {
		return orderDertyHistory;
	}

	public void setOrderDertyHistory(OrderDertyHistory orderDertyHistory) {
		this.orderDertyHistory = orderDertyHistory;
	}

	public OrderDertyHistoryService getOrderDertyHistoryService() {
		return orderDertyHistoryService;
	}

	public void setOrderDertyHistoryService(
			OrderDertyHistoryService orderDertyHistoryService) {
		this.orderDertyHistoryService = orderDertyHistoryService;
	}

	public void setWorkPattern1(String workPattern1) {
		this.workPattern1 = workPattern1;
	}

	public Date getStartTimes() {
		return startTimes;
	}

	public void setStartTimes(Date startTimes) {
		this.startTimes = startTimes;
	}

	public Date getEndTimes() {
		return endTimes;
	}

	public void setEndTimes(Date endTimes) {
		this.endTimes = endTimes;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public String getComName() {
		return comName;
	}

	public void setComName(String comName) {
		this.comName = comName;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public String getCustomerTel() {
		return customerTel;
	}

	public void setCustomerTel(String customerTel) {
		this.customerTel = customerTel;
	}

	public OrderConnecting getOrderConnecting() {
		return OrderConnecting;
	}

	public void setOrderConnecting(OrderConnecting orderConnecting) {
		OrderConnecting = orderConnecting;
	}

	public OrderConnectingService getOrderConnectingService() {
		return orderConnectingService;
	}

	public void setOrderConnectingService(
			OrderConnectingService orderConnectingService) {
		this.orderConnectingService = orderConnectingService;
	}

	public MidBusinessOrder getMidBusinessOrder() {
		return midBusinessOrder;
	}

	public void setMidBusinessOrder(MidBusinessOrder midBusinessOrder) {
		this.midBusinessOrder = midBusinessOrder;
	}

	public MidBusinessOrderService getMidBusinessOrderService() {
		return midBusinessOrderService;
	}

	public void setMidBusinessOrderService(
			MidBusinessOrderService midBusinessOrderService) {
		this.midBusinessOrderService = midBusinessOrderService;
	}

	public String getOrderState() {
		return orderState;
	}

	public void setOrderState(String orderState) {
		this.orderState = orderState;
	}

	/*
	 * 短信發送接口 发送方法 其他方法同理 输入参数： CorpID-帐号， Pwd-密码， Mobile-发送手机号， Content-发送内容，
	 * Cell-子号(可为空），
	 * SendTime-定时发送时间(固定14位长度字符串，比如：20060912152435代表2006年9月12日15时24分35秒，可为空)
	 * 输出参数：整数 0，发送成功； -1、帐号未注册； -2、其他错误； -3、密码错误； -4、手机号格式不对； -5、余额不足；
	 * -6、定时发送时间不是有效的时间格式； 注意：禁止10小时以内向同一手机号发送相同短信；
	 */

	@SuppressWarnings("unused")
	private static int sendSMS4Other(String Mobile, String Content,
			String send_time) throws MalformedURLException,
			UnsupportedEncodingException {
		ResourceBundle rb = ResourceBundle.getBundle("note");
		URL url = null;
		String CorpID = rb.getString("userName");// 账户名
		String Pwd = rb.getString("password");// 密码
		String send_content = URLEncoder.encode(
				Content.replaceAll("<br/>", " "), "GBK");// 发送内容
		url = new URL("http://mb345.com/WS/Send.aspx?CorpID=" + CorpID
				+ "&Pwd=" + Pwd + "&Mobile=" + Mobile + "&Content="
				+ send_content + "&Cell=&SendTime=" + send_time);
		BufferedReader in = null;
		int inputLine = 0;
		try {
			//System.out.println("开始发送短信手机号码为 ：" + Mobile);
			in = new BufferedReader(new InputStreamReader(url.openStream()));
			inputLine = new Integer(in.readLine()).intValue();
		} catch (Exception e) {
			//System.out.println("网络异常,发送短信失败！");
			inputLine = -9;
		}
		//System.out.println("结束发送短信返回值：  " + inputLine);
		return inputLine;
	}

	public NoteInformationService getNoteInformationService() {
		return noteInformationService;
	}

	public void setNoteInformationService(
			NoteInformationService noteInformationService) {
		this.noteInformationService = noteInformationService;
	}

	public String getOrderCode() {
		return orderCode;
	}

	public void setOrderCode(String orderCode) {
		this.orderCode = orderCode;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public int getInitsNum() {
		return initsNum;
	}

	public void setInitsNum(int initsNum) {
		this.initsNum = initsNum;
	}

	public String getStarts() {
		return starts;
	}

	public void setStarts(String starts) {
		this.starts = starts;
	}

	public String getEnds() {
		return ends;
	}

	public void setEnds(String ends) {
		this.ends = ends;
	}

	public Integer getEncode() {
		return Encode;
	}

	public void setEncode(Integer encode) {
		Encode = encode;
	}

	public Integer getComNameByid() {
		return comNameByid;
	}

	public void setComNameByid(Integer comNameByid) {
		this.comNameByid = comNameByid;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getCusName() {
		return cusName;
	}

	public void setCusName(String cusName) {
		this.cusName = cusName;
	}

	public String getCusTel() {
		return cusTel;
	}

	public void setCusTel(String cusTel) {
		this.cusTel = cusTel;
	}

	public String getInitreserve() {
		return initreserve;
	}

	public void setInitreserve(String initreserve) {
		this.initreserve = initreserve;
	}

	public LogSerchService getLogSerchService() {
		return logSerchService;
	}

	public void setLogSerchService(LogSerchService logSerchService) {
		this.logSerchService = logSerchService;
	}

	public BusinessRemind getBusinessRemind() {
		return businessRemind;
	}

	public void setBusinessRemind(BusinessRemind businessRemind) {
		this.businessRemind = businessRemind;
	}

	public BusinessRemindService getBusinessRemindService() {
		return businessRemindService;
	}

	public void setBusinessRemindService(
			BusinessRemindService businessRemindService) {
		this.businessRemindService = businessRemindService;
	}

	public PersonService getPersonService() {
		return personService;
	}

	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}

	public NoteEditor getNoteEditor() {
		return noteEditor;
	}

	public void setNoteEditor(NoteEditor noteEditor) {
		this.noteEditor = noteEditor;
	}

	public NoteEditorService getNoteEditorService() {
		return noteEditorService;
	}

	public void setNoteEditorService(NoteEditorService noteEditorService) {
		this.noteEditorService = noteEditorService;
	}

	public String getContents(Services sss, Company com) {
		Services ss = this.getServicesService().get(sss.getId());
		List<NoteEditor> neList = this.getNoteEditorService()
				.getByServicesNoteEditor(ss);
		String contents = "";
		for (NoteEditor ne : neList) {
			String ser[] = (ne.getSerialName()).split(",");
			for (String s : ser) {
				if ("".equals(s)) {

				} else {
					if (com.getId() == Integer.parseInt(s)) {
						contents = ne.getInforMo();
					}
				}

			}

		}
		return contents;
	}

	public List<Services> getSerList() {
		return serList;
	}

	public void setSerList(List<Services> serList) {
		this.serList = serList;
	}

	public String getConditionss() {
		return conditionss;
	}

	public void setConditionss(String conditionss) {
		this.conditionss = conditionss;
	}

	public String getSortStyle() {
		return sortStyle;
	}

	public void setSortStyle(String sortStyle) {
		this.sortStyle = sortStyle;
	}

	public String getBargainState() {
		return bargainState;
	}

	public void setBargainState(String bargainState) {
		this.bargainState = bargainState;
	}

	public Integer getServerids() {
		return serverids;
	}

	public void setServerids(Integer serverids) {
		this.serverids = serverids;
	}

	public String getDateSletct() {
		return dateSletct;
	}

	public void setDateSletct(String dateSletct) {
		this.dateSletct = dateSletct;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public String getTeanTim() {
		return teanTim;
	}

	public void setTeanTim(String teanTim) {
		this.teanTim = teanTim;
	}

	public Integer getServiceClass() {
		return serviceClass;
	}

	public void setServiceClass(Integer serviceClass) {
		this.serviceClass = serviceClass;
	}

	public Integer getServerIdsss() {
		return serverIdsss;
	}

	public void setServerIdsss(Integer serverIdsss) {
		this.serverIdsss = serverIdsss;
	}

	public String getProcessState() {
		return processState;
	}

	public void setProcessState(String processState) {
		this.processState = processState;
	}

	public String getGsA() {
		return gsA;
	}

	public void setGsA(String gsA) {
		this.gsA = gsA;
	}

	public String getGsB() {
		return gsB;
	}

	public void setGsB(String gsB) {
		this.gsB = gsB;
	}

}
